package net.obxlabs.tweetpad.behaviour;

import net.nexttext.*;
import net.nexttext.behaviour.*;
import net.nexttext.behaviour.control.*;
import net.nexttext.behaviour.standard.*;
import net.silentlycrashing.gestures.*;

/**
 * A Condition that is true when the passed GestureListener is active.
 */ 
/* $Id:OnConcurrentGesture.java 16 2007-11-27 10:50:46Z prisonerjohn $ */
public class OnConcurrentGesture extends Condition {
	protected ConcurrentGestureListener ear;
	
	public OnConcurrentGesture(ConcurrentGestureListener gestureListener, Action trueAction) {
		this(gestureListener, trueAction, new DoNothing());
	}
	
	public OnConcurrentGesture(ConcurrentGestureListener gestureListener, Action trueAction, Action falseAction) {
		super(trueAction, falseAction);
		ear = gestureListener;
	}
	
	public boolean condition(TextObject to) {
		return (ear.isActive() && to.getBounds().contains(ear.getStartPoint()));
	}
}
